package org.jeecg.modules.externalEquity.entity;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Author: yinhm
 * @Date: 2025-04-24 14:48
 * @Version: V1.0
 */



@Data
public class ExternalEquitySummary {
    public String companyName;
    public String orgCode;
    public String companyLevel;
    public BigDecimal initialInvestmentCost;
    public BigDecimal cumulativeOriginalValue;
    public BigDecimal cumulativeNetValue;
    public BigDecimal cumulativeIncomeReceivable;
    public BigDecimal cumulativeIncomeReceived;
    public BigDecimal currentYearIncomeReceived;
    public List<TbExternalEquity> externalEquityList; // 存储汇总所基于的原始数据


    public ExternalEquitySummary(String companyName, String orgCode, String companyLevel, BigDecimal initialInvestmentCost, BigDecimal cumulativeOriginalValue, BigDecimal cumulativeNetValue, BigDecimal cumulativeIncomeReceivable, BigDecimal cumulativeIncomeReceived, BigDecimal currentYearIncomeReceived, List<TbExternalEquity> externalEquityList) {
        this.companyName = companyName;
        this.orgCode = orgCode;
        this.companyLevel = companyLevel;
        this.initialInvestmentCost = initialInvestmentCost;
        this.cumulativeOriginalValue = cumulativeOriginalValue;
        this.cumulativeNetValue = cumulativeNetValue;
        this.cumulativeIncomeReceivable = cumulativeIncomeReceivable;
        this.cumulativeIncomeReceived = cumulativeIncomeReceived;
        this.currentYearIncomeReceived = currentYearIncomeReceived;
        this.externalEquityList = externalEquityList;
    }

    public void addInitialInvestmentCost(BigDecimal initialInvestmentCost) {
        if (this.initialInvestmentCost == null) {
            this.initialInvestmentCost = BigDecimal.ZERO;
        }
        if (initialInvestmentCost != null) {
            this.initialInvestmentCost = this.initialInvestmentCost.add(initialInvestmentCost);
        }
    }

    public void addCumulativeOriginalValue(BigDecimal cumulativeOriginalValue) {
        if (this.cumulativeOriginalValue == null) {
            this.cumulativeOriginalValue = BigDecimal.ZERO;
        }
        if (cumulativeOriginalValue != null) {
            this.cumulativeOriginalValue = this.cumulativeOriginalValue.add(cumulativeOriginalValue);
        }
    }

    public void addCumulativeNetValue(BigDecimal cumulativeNetValue) {
        if (this.cumulativeNetValue == null) {
            this.cumulativeNetValue = BigDecimal.ZERO;
        }
        if (cumulativeNetValue != null) {
            this.cumulativeNetValue = this.cumulativeNetValue.add(cumulativeNetValue);
        }
    }

    public void addCumulativeIncomeReceivable(BigDecimal cumulativeIncomeReceivable) {
        if (this.cumulativeIncomeReceivable == null) {
            this.cumulativeIncomeReceivable = BigDecimal.ZERO;
        }
        if (cumulativeIncomeReceivable != null) {
            this.cumulativeIncomeReceivable = this.cumulativeIncomeReceivable.add(cumulativeIncomeReceivable);
        }
    }

    public void addCumulativeIncomeReceived(BigDecimal cumulativeIncomeReceived) {
        if (this.cumulativeIncomeReceived == null) {
            this.cumulativeIncomeReceived = BigDecimal.ZERO;
        }
        if (cumulativeIncomeReceived != null) {
            this.cumulativeIncomeReceived = this.cumulativeIncomeReceived.add(cumulativeIncomeReceived);
        }
    }

    public void addCurrentYearIncomeReceived(BigDecimal currentYearIncomeReceived) {
        if (this.currentYearIncomeReceived == null) {
            this.currentYearIncomeReceived = BigDecimal.ZERO;
        }
        if (currentYearIncomeReceived != null) {
            this.currentYearIncomeReceived = this.currentYearIncomeReceived.add(currentYearIncomeReceived);
        }
    }

    // 深拷贝方法
    public ExternalEquitySummary deepCopy() {
        return new ExternalEquitySummary(
                this.companyName,
                this.orgCode,
                this.companyLevel,
                this.initialInvestmentCost,
                this.cumulativeOriginalValue,
                this.cumulativeNetValue,
                this.cumulativeIncomeReceivable,
                this.cumulativeIncomeReceived,
                this.currentYearIncomeReceived,
                this.externalEquityList
        );
    }
}
